package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.fgs.common.pictureSelector.GlideEngine;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.constant.Config;
import com.tianhui.consignortwofei.mvp.model.QuotationListBean;


import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2020/4/1
 * @description
 **/
public class QuotationListAdapter extends RecyclerArrayAdapter<QuotationListBean.QuotationRecords> {


    private Context mContext ;
    private int lookType;


    public QuotationListAdapter(Context context,int lookType) {//, IOrderStatus iOrderStatus
        super(context);
        mContext=context;
        this.lookType=lookType;
//        this.iOrderStatus = iOrderStatus;
    }



    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        newsSmallImgViewHolder viewHolder = new newsSmallImgViewHolder(parent, R.layout.item_quotation_list);
        return viewHolder;

    }






    public class newsSmallImgViewHolder extends BaseViewHolder<QuotationListBean.QuotationRecords> {
//        private TextView numberTextView;
//        private ImageView bigTvImage;
        private TextView tv_baojia;
        private TextView tv_baojia_time;
        private TextView tv_baojia_type;

        private TextView tv_content;
        private TextView tv_shenhe;
        private TextView tv_shenhe_time;
        private TextView tv_beizhu;
        private TextView tv_zankai;
        private ImageView iv_zankai_icon;

        private TextView tv_xiugai;
        private TextView tv_shanchu;

        private ImageView iv_image;

//        private RecyclerView rv_option_body;




        public newsSmallImgViewHolder(ViewGroup parent, int res) {
            super(parent, res);
//            numberTextView = getView(R.id.item_order_list_numberTextView);
//            bigTvImage = (ImageView) getView(R.id.big_tv_image);
            tv_baojia = (TextView) getView(R.id.tv_baojia);
            tv_baojia_time = (TextView) getView(R.id.tv_baojia_time);
            tv_baojia_type = (TextView) getView(R.id.tv_baojia_type);

            tv_content = (TextView) getView(R.id.tv_content);
            tv_shenhe = (TextView) getView(R.id.tv_shenhe);
            tv_shenhe_time = (TextView) getView(R.id.tv_shenhe_time);
            tv_beizhu = (TextView) getView(R.id.tv_beizhu);

            tv_zankai = (TextView) getView(R.id.tv_zankai);
            iv_zankai_icon = (ImageView) getView(R.id.iv_zankai_icon);

            tv_xiugai = (TextView) getView(R.id.tv_xiugai);
            tv_shanchu = (TextView) getView(R.id.tv_shanchu);

//            rv_option_body = (RecyclerView) getView(R.id.rv_option_body);

            iv_image = (ImageView) getView(R.id.iv_image);


            addOnClickListener(R.id.ll_zhankai_boady);
            addOnClickListener(R.id.tv_xiugai);
            addOnClickListener(R.id.tv_shanchu);
//            bigTvTime = (TextView) getView(R.id.big_tv_time);
//            bigTvCommentNum = (TextView) getView(R.id.big_tv_comment_num);
//            bigIvComment = (ImageView) getView(R.id.big_iv_comment);
//            bigTvLikeNum = (TextView) getView(R.id.big_tv_like_num);
//            bigIvLike = (ImageView) getView(R.id.big_iv_like);

        }

        @Override
        public void setData(QuotationListBean.QuotationRecords data) {
            super.setData(data);

            tv_baojia.setText(data.getUsername());
            tv_baojia_time.setText(data.getCreate_time());

            GlideEngine.createGlideEngine().loadImage(mContext,Config.baseImageUrl+data.getImgpicture(),iv_image);

            tv_baojia_type.setText(data.getStatusname());
            tv_content.setText("报价内容："+data.getContent());
            tv_shenhe.setText("审核人："+data.getVerifyusername());
            tv_shenhe_time.setText("审核时间："+data.getVerifytime());

            tv_beizhu.setText(data.getRemarks());

            if (data.isZhankai()){
                tv_zankai.setText("收起");
                iv_zankai_icon.setImageResource(R.mipmap.icon_blue_right);
            }else {
                tv_zankai.setText("展开");
                iv_zankai_icon.setImageResource(R.mipmap.icon_blue_down);
            }

            addOnClickListener(R.id.tv_xiugai);
            addOnClickListener(R.id.tv_shanchu);
//            if (1==lookType){
//                tv_xiugai.setVisibility(View.VISIBLE);
//                tv_shanchu.setVisibility(View.VISIBLE);
//                tv_baojia_type.setVisibility(View.VISIBLE);
//            }else {
                tv_xiugai.setVisibility(View.GONE);
                tv_shanchu.setVisibility(View.GONE);
                tv_baojia_type.setVisibility(View.GONE);
//            }





////            List<SubjectTalkListBean.SubjectTalkRecords.SubjectTalkDetails> details = data.getDetails();
//
//            rv_option_body.setFocusable(false);
//            if (null!=data.getPlasticsQuotationList()&&data.getPlasticsQuotationList().size()>0) {
//                rv_option_body.setVisibility(View.VISIBLE);
////            MyLinearLayoutManager linearLayoutManager = new MyLinearLayoutManager(getContext());
//                MyLinearLayoutManager linearLayoutManager = new MyLinearLayoutManager(getContext(),
//                        LinearLayoutManager.VERTICAL, false) {
//                    @Override
//                    public boolean canScrollVertically() {
//                        return false;
//                    }
//                };
////            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//                rv_option_body.setLayoutManager(linearLayoutManager);
//                QuotationSecindItemAdapter homeListAdapter = new QuotationSecindItemAdapter(getContext());
//                rv_option_body.setAdapter(homeListAdapter);
////            homeListAdapter.clear();
//                homeListAdapter.addAll(data.getPlasticsQuotationList());
////                homeListAdapter.setOnItemClickListener(new OnItemClickListener() {
////
////                    @Override
////                    public void onItemClick(int position) {
////
//////                        SubjectTalkListBean.SubjectTalkRecords subjectTalkRecords = newsListAdapter.getAllData().get(position);
////                        if (data == null) {
////                            return;
////                        }
////                        Intent intent=new Intent(mContext, HuatiDetailActivity.class);
////                        intent.putExtra("beanId",data.getId());
////                        mContext.startActivity(intent);
////                    }
////                });
//
//            }
////            else {
////                rv_option_body.setVisibility(View.GONE);
////            }




        }
    }




}
